#if !defined(__TEXTE_EDITABLE_H)
#define __TEXTE_EDITABLE_H

#include "interface.h"
#include "surface_texte.h"
#include "observateur_evenement.h"
#include <string>

struct valider_tout {
	bool operator()(char nouveau_caractere) {
		return true;
	}
};

struct valider_adresses_et_hotes {
	bool operator()(char touche) {
		return (touche >= 'a' && touche <= 'z') || (touche >= 'A' && touche <= 'Z') || (touche >= '0' && touche <= '9') || touche == ':' || touche == '.';
	}
};

struct valider_chiffres {
	bool operator()(char touche) {
		return (touche >= '0' && touche <= '9');
	}
};

template <class ValidateurCaractere = valider_tout>
class texte_editable : public observateur_evenement {
	ValidateurCaractere validateur_;
	std::string suffixe_;
	std::string texte_entre_;
	surface_texte ma_surface_;
	bool touche_entree_appuyee_;
	
	void changer_texte();
public:
	texte_editable(std::string texte_par_defaut, bool g = true, int x = 0, int y = 0, bool v = true, int z = 0, std::string suffixe = "_", ValidateurCaractere val = ValidateurCaractere()) throw();
	~texte_editable() throw() {}
	
	void souris_cliquee(int,int,bool) {}
	void touche_pressee(int,int,bool);
	
	std::string texte_entre() { return texte_entre_; }
	void texte_entre(std::string nouveau);
	
	bool touche_entree_appuyee() { return touche_entree_appuyee_; }
	
	bool visible() const { return ma_surface_.visible(); }
	void visible(bool v) { ma_surface_.visible(v); }
};

#include "texte_editable.hpp"

#endif
